var itema = document.querySelectorAll(".lunBo .content li");
var lis = document.querySelectorAll(".controls ul li");
var lbtn = document.getElementById("lBtn");
var rbtn = document.getElementById("rBtn");
var count = 0;

for(var i = 0;i<lis.length;i++){
	lis[i].index = i;
	lis[i].onclick = function(){
		count = this.index;
		chang();
	}
}

var time;
function autoPlay(){
	time = setInterval(function(){
		count++;
		count%=5;
		chang();
	},3000)
}


function chang(){
	for(var j = 0;j<lis.length;j++){
		itema[j].className = "lunBo-item";
		itema[j].style.opacity = "0";
		itema[j].style.filter = "alpha(opacity=0)";
		lis[j].className = "";
	}
	lis[count].className = "action";
	itema[count].className = "lunBo-itema active default";
	animate(itema[count],{opacity:100},30);
}

itema.onmouseenter = function(){
	clearInterval(time);
}
itema.onmouseleave = function(){
	autoPlay();
}
autoPlay();

rbtn.onclick = function(){
	count = count+1;
	count%=5;
	chang();
}
lbtn.onclick = function(){
	if(count>0){
		count = count-1;
	}else{
		count = 4;		
	}
	count%=5;
	chang();
}
